package com.ym.controller.medical;

import com.github.pagehelper.PageInfo;
import com.ym.common.utils.page.PageDomain;
import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.param.UserDoctorViewQueryParam;
import com.ym.medical.domain.param.UserPatientViewQueryParam;
import com.ym.medical.domain.param.UserStateUpdateParam;
import com.ym.medical.domain.vo.UserDoctorViewListPcVO;
import com.ym.medical.domain.vo.UserPatientViewListPcVO;
import com.ym.medical.service.IUserDoctorViewSV;
import com.ym.medical.service.IUserPatientViewSV;
import com.ym.medical.service.IUserSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * 综合管理中心
 */
@Api(tags = "medical- 账号管理")
@Controller
@RequestMapping("/medical/accout")
public class AccountManagement extends BaseController {
	@Autowired
	private IUserSV iUserSV;

	@Autowired
	private IUserPatientViewSV userPatientViewSV;

	@Autowired
	private IUserDoctorViewSV userDoctorViewSV;

	@ApiOperation("患者账号列表")
	@GetMapping("/getPatientList")
	@ResponseBody
	public APIResponse<PageInfo<UserPatientViewListPcVO>> getPatientList(UserPatientViewQueryParam queryParam) {
		PageDomain.startPage();
		List<UserPatientViewListPcVO> userPatientViewListPcVOS = userPatientViewSV.selectListPC(queryParam);
		return successPage(userPatientViewListPcVOS);

	}

	@ApiOperation("医生账号列表")
	@GetMapping("/getDoctorList")
	@ResponseBody
	public APIResponse<PageInfo<UserDoctorViewListPcVO>> getDoctorList(UserDoctorViewQueryParam queryParam) {
		PageDomain.startPage();
		List<UserDoctorViewListPcVO> userPatientViewListPcVOS = userDoctorViewSV.selectListPC(queryParam);
		return successPage(userPatientViewListPcVOS);
	}


	@Log
	@ApiOperation("账号禁用")
	@PostMapping("/disableUser")
	@ResponseBody
	public APIResponse disableUser(@RequestBody UserStateUpdateParam param) {
		iUserSV.disableUser(param.getUserIds(), param.getUserUserType());
		return successMsg("操作成功");
	}

	@Log
	@ApiOperation("账号启用")
	@PostMapping("/enableUser")
	@ResponseBody
	public APIResponse enableUser(@RequestBody UserStateUpdateParam param) {
		iUserSV.enableUser(param.getUserIds(), param.getUserUserType());
		return successMsg("操作成功");
	}

}
